package com.xidian.zhiancloud.service.riskcontrol.riskidenva;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xidian.zhiancloud.dao.riskcontrol.riskidenva.TRiskJobCheckItemMapper;
import com.xidian.zhiancloud.model.riskcontrol.TRiskJobCheckItemList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 作业活动清单-检查项
 */
@Service
public class TRiskJobCheckItemService extends ServiceImpl
        <TRiskJobCheckItemMapper, TRiskJobCheckItemList> {

    @Autowired
    TRiskJobCheckItemMapper tRiskJobCheckItemMapper;

    //风险辨识-风险辨识-作业活动清单-检查项添加
    public int insertJobCheckItems(TRiskJobCheckItemList jobCheckItems){
        return tRiskJobCheckItemMapper.insertJobCheckItems(jobCheckItems);
    }

    //风险辨识-风险辨识-作业活动清单-检查项编辑
    public int updateJobCheckItems(String id,TRiskJobCheckItemList jobCheckItems){
        return tRiskJobCheckItemMapper.updateJobCheckItems
                (Long.valueOf(id),jobCheckItems);
    }

    //风险辨识-风险辨识-删除检查项
    public int deleteJobCheckItems(String id){
        List<String> lists = getList(id);
        return tRiskJobCheckItemMapper.deleteJobCheckItems(lists);
    }

    /**
     * id放入list
     * @param id id(多个已逗号分隔)
     * @return List集合
     */
    public List<String> getList(String id) {
        List<String> list = new ArrayList<String>();
        String[] str = id.split(",");
        for (int i = 0; i < str.length; i++) {
            list.add(str[i]);
        }
        return list;
    }

    public List<TRiskJobCheckItemList> getByIds(Long companyId, String taskAllocatId){
        return tRiskJobCheckItemMapper.getByIds(companyId,taskAllocatId);
    }

}
